Page({
  data: {
      address_list: null
  },
  bianji:function(res){
console.log(res.currentTarget.dataset.id,'编辑')
var id=res.currentTarget.dataset.id;
wx.navigateTo({
  url: '/pages/address-edit2/address-edit2?id=' + id,
})
  },
//   shanchu:function(res){
// console.log(res.currentTarget.dataset.id,'删除')
// console.log(res.currentTarget,'删除')

// console.log(this ,'shanchuaa')

// console.log(this.__data__.address_list  ,'shanchu')
//   },

  shanchu:function(res) {
    var id = res.currentTarget.dataset.id,
      index = this.__data__.address_list,
      s = this;
    if (id > 0) {
      wx.showModal({
        title: '提示',
        content: '是否删除？',
        confirmText: "删除",
        success(res) {
          console.log(res,'按钮')
          // if (res.confirm) {
          //   getApp().core.showLoading({
          //     title: "加载中"
          //   }), getApp().request({
          //     url: getApp().api.weitao.delete_article,
          //     data: {
          //       article_id: article_id,
          //     },
          //     success: function (t) {
          //       s.data.list.splice(index, 1);
          //       if (t.code == 0) {
          //         s.setData({
          //           list: s.data.list
          //         });
          //         // s.getUser();
          //       }
          //       getApp().core.showToast({
          //         title: t.msg,
          //         icon: 'none'
          //       });
          //     },
          //     complete: function () {
          //       getApp().core.hideLoading();
          //     }
          //   });


          // }
        }
      })

    } else {
      getApp().core.showToast({
        title: "系统错误",
        icon: 'none'
      });
    }
  },



  onLoad: function(e) {
      getApp().page.onLoad(this, e);
  },
  onShow: function() {
      getApp().page.onShow(this);
      var t = this;
      getApp().core.showNavigationBarLoading(), getApp().request({
          url: getApp().api.user.address_list,
          success: function(e) {
            console.log(e,'列表')
              getApp().core.hideNavigationBarLoading(), 0 == e.code && t.setData({
                  address_list: e.data.list,
              });
          }
      });
  },
  pickAddress: function(e) {
      var t = e.currentTarget.dataset.index, a = this.data.address_list[t];
      getApp().core.setStorageSync(getApp().const.PICKER_ADDRESS, a), getApp().core.navigateBack();
  },
  getWechatAddress: function(e) {
      getApp().core.chooseAddress({
          success: function(e) {
              "chooseAddress:ok" == e.errMsg && (getApp().core.showLoading(), getApp().request({
                  url: getApp().api.user.add_wechat_address,
                  method: "post",
                  data: {
                      national_code: e.nationalCode,
                      name: e.userName,
                      mobile: e.telNumber,
                      detail: e.detailInfo,
                      province_name: e.provinceName,
                      city_name: e.cityName,
                      county_name: e.countyName
                  },
                  success: function(e) {
                      1 != e.code ? 0 == e.code && (getApp().core.setStorageSync(getApp().const.PICKER_ADDRESS, e.data), 
                      getApp().core.navigateBack()) : getApp().core.showModal({
                          title: "提示",
                          content: e.msg,
                          showCancel: !1
                      });
                  },
                  complete: function() {
                      getApp().core.hideLoading();
                  }
              }));
          }
      });
  }
});